package nape.dynamics;
import zpp_nape.Config;
import zpp_nape.Const;
import zpp_nape.util.Flags;
import DummyNapeMain;
import zpp_nape.util.Math;
import zpp_nape.util.Names;
import zpp_nape.util.Pool;
import zpp_nape.util.Lists;
import zpp_nape.shape.Circle;
import zpp_nape.shape.Edge;
import zpp_nape.space.Space;
import zpp_nape.shape.Polygon;
import zpp_nape.shape.Shape;
import zpp_nape.phys.FeatureMix;
import zpp_nape.phys.FluidProperties;
import zpp_nape.phys.Material;
import zpp_nape.phys.Body;
import zpp_nape.geom.AABB;
import zpp_nape.geom.Distance;
import zpp_nape.geom.Mat23;
import zpp_nape.geom.Vec2;
import zpp_nape.geom.VecMath;
import zpp_nape.geom.Collide;
import zpp_nape.dynamics.Arbiter;
import zpp_nape.dynamics.Contact;
import zpp_nape.dynamics.InteractionFilter;
import zpp_nape.constraint.Constraint;
import zpp_nape.dynamics.SpaceArbiterList;
import zpp_nape.constraint.Matrices;
import zpp_nape.constraint.PivotJoint;
import zpp_nape.constraint.WeldJoint;
import nape.util.Flags;
import nape.util.Lists;
import nape.util.Debug;
import nape.space.Space;
import nape.shape.Circle;
import nape.shape.Polygon;
import nape.shape.Edge;
import nape.shape.Shape;
import nape.phys.FluidProperties;
import nape.phys.Material;
import nape.phys.Body;
import nape.geom.AABB;
import nape.geom.Geom;
import nape.geom.Mat23;
import nape.geom.Vec2;
import nape.dynamics.Contact;
import nape.dynamics.Arbiter;
#if swc@:keep#end class InteractionFilter{
    public var zpp_inner:ZPP_InteractionFilter;
    public var shared(flibget_shared,flibset_shared):Bool;
    inline function flibget_shared()return zpp_inner.shared inline function flibset_shared(shared:Bool){
        if(this.shared!=shared){
            if(this.shared&&!zpp_inner.shapes.empty()){
                while(zpp_inner.shapes.begin().next!=null){
                    var s=zpp_inner.shapes.pop_unsafe();
                    s.filter=zpp_inner.copy();
                    s.filter.shapes.add(s);
                }
            }
            zpp_inner.shared=shared;
        }
        return this.shared;
    }
    public var shapes(flibget_shapes,never):ShapeList;
    inline function flibget_shapes(){
        if(zpp_inner.wrap_shapes==null)zpp_inner.wrap_shapes=ZPP_ShapeList.get(zpp_inner.shapes,true);
        return zpp_inner.wrap_shapes;
    }
    public var collisionGroup(flibget_collisionGroup,flibset_collisionGroup):Int;
    inline function flibget_collisionGroup()return zpp_inner.collisionGroup inline function flibset_collisionGroup(collisionGroup:Int){
        if(this.collisionGroup!=collisionGroup){
            zpp_inner.collisionGroup=collisionGroup;
            zpp_inner.invalidate();
        }
        return zpp_inner.collisionGroup;
    }
    public var collisionMask(flibget_collisionMask,flibset_collisionMask):Int;
    inline function flibget_collisionMask()return zpp_inner.collisionMask inline function flibset_collisionMask(collisionMask:Int){
        if(this.collisionMask!=collisionMask){
            zpp_inner.collisionMask=collisionMask;
            zpp_inner.invalidate();
        }
        return zpp_inner.collisionMask;
    }
    public var sensorGroup(flibget_sensorGroup,flibset_sensorGroup):Int;
    inline function flibget_sensorGroup()return zpp_inner.sensorGroup inline function flibset_sensorGroup(sensorGroup:Int){
        if(this.sensorGroup!=sensorGroup){
            zpp_inner.sensorGroup=sensorGroup;
            zpp_inner.invalidate();
        }
        return zpp_inner.sensorGroup;
    }
    public var sensorMask(flibget_sensorMask,flibset_sensorMask):Int;
    inline function flibget_sensorMask()return zpp_inner.sensorMask inline function flibset_sensorMask(sensorMask:Int){
        if(this.sensorMask!=sensorMask){
            zpp_inner.sensorMask=sensorMask;
            zpp_inner.invalidate();
        }
        return zpp_inner.sensorMask;
    }
    public var fluidGroup(flibget_fluidGroup,flibset_fluidGroup):Int;
    inline function flibget_fluidGroup()return zpp_inner.fluidGroup inline function flibset_fluidGroup(fluidGroup:Int){
        if(this.fluidGroup!=fluidGroup){
            zpp_inner.fluidGroup=fluidGroup;
            zpp_inner.invalidate();
        }
        return zpp_inner.fluidGroup;
    }
    public var fluidMask(flibget_fluidMask,flibset_fluidMask):Int;
    inline function flibget_fluidMask()return zpp_inner.fluidMask inline function flibset_fluidMask(fluidMask:Int){
        if(this.fluidMask!=fluidMask){
            zpp_inner.fluidMask=fluidMask;
            zpp_inner.invalidate();
        }
        return zpp_inner.fluidMask;
    }
    public function new(?collisionGroup=1,?collisionMask=-1,?sensorGroup=1,?sensorMask=-1,?fluidGroup=1,?fluidMask=-1){
        zpp_inner={
            if(ZPP_InteractionFilter.zpp_pool==null)new ZPP_InteractionFilter();
            else{
                var ret=ZPP_InteractionFilter.zpp_pool;
                ZPP_InteractionFilter.zpp_pool=ret.next;
                ret;
            }
        };
        zpp_inner.outer=this;
        this.collisionGroup=collisionGroup;
        this.collisionMask=collisionMask;
        this.sensorGroup=sensorGroup;
        this.sensorMask=sensorMask;
        this.fluidGroup=fluidGroup;
        this.fluidMask=fluidMask;
    }
    #if swc@:keep#end public inline function shouldCollide(filter:InteractionFilter)return zpp_inner.shouldCollide(filter.zpp_inner)#if swc@:keep#end public inline function shouldSense(filter:InteractionFilter)return zpp_inner.shouldSense(filter.zpp_inner)#if swc@:keep#end public inline function shouldFlow(filter:InteractionFilter)return zpp_inner.shouldFlow(filter.zpp_inner)#if swc@:keep#end public inline function copy()return new InteractionFilter(collisionGroup,collisionMask,sensorGroup,sensorMask,fluidGroup,fluidMask)#if swc@:keep#end public inline function toString(){
        return "{ collision: "+StringTools.hex(collisionGroup,8)+"~"+StringTools.hex(collisionMask,8)+" sensor: "+StringTools.hex(sensorGroup,8)+"~"+StringTools.hex(sensorMask,8)+" fluid: "+StringTools.hex(fluidGroup,8)+"~"+StringTools.hex(fluidMask,8)+" }";
    }
}
